package Forms;

import Controls.Button;
import Controls.CheckBox;
import Controls.Group;
import Controls.Line;
import Controls.RadioButton;
import Controls.RadioGroup;
import Controls.Text;
import old_Core.AlternateCore;
import Core.Form;
import Core.GM;
import Core.RecordManager;

public class Options extends Form
{
	private RadioGroup angleGroup;

	public Options()
	{
		super(Form.HEAD | Form.THIN_PANEL);

		body.h_border = 4;
		//body.v_border = 20;

		body.scrollEnable = true;

		angleGroup = new RadioGroup(body);
		angleGroup.addRadioButton("Degrees");
		angleGroup.addRadioButton("Radians");
		angleGroup.addRadioButton("Grads");

		//for(int i=0; i<20; i++) body.addControl(new Button(""+(i+1), body));

		angleGroup.setSelect(RecordManager.getRecord("CalcForm.angle", AlternateCore.ANGLE_RADIAN));

		body.addControl(new Text("Default angle units:", body.getAvailableW()-4, true));
		body.addControl(angleGroup);

		setWindowText(GM.FORM_CAPTION, "Options");
		setWindowText(GM.PANEL_LEFTSOFT, "Accept");
		setWindowText(GM.PANEL_RIGHTSOFT, "Cancel");
	}

	public void onEvent(int event, Object param)
	{
		super.onEvent(event, param);

		if(event == GM.PANEL_LEFTSOFT)
		{
			RecordManager.setRecord("CalcForm.angle", angleGroup.getSelect(AlternateCore.ANGLE_RADIAN));
			close();
		}
		else if(event == GM.PANEL_RIGHTSOFT)
		{
			close();
		}
	}
}
